/* FunChat 表单样式 - 参考飞书风格 */

/* 表单控件基础样式 */
.form-control {
  display: block;
  width: 100%;
  height: 36px;
  padding: var(--spacing-mini) var(--spacing-small);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  line-height: 1.5;
  color: var(--text-color-primary);
  background-color: var(--background-color-primary);
  background-clip: padding-box;
  border: 1px solid var(--border-color-normal);
  border-radius: var(--border-radius-base);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
  color: var(--text-color-primary);
  background-color: var(--background-color-primary);
  border-color: var(--primary-color);
  outline: 0;
  box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.2);
}

.form-control::placeholder {
  color: var(--text-color-tertiary);
  opacity: 1;
}

.form-control:disabled,
.form-control[readonly] {
  background-color: var(--background-color-secondary);
  opacity: 0.7;
  cursor: not-allowed;
}

/* 表单组 */
.form-group {
  margin-bottom: var(--spacing-medium);
}

.form-label {
  display: inline-block;
  margin-bottom: var(--spacing-mini);
  font-weight: var(--font-weight-medium);
  color: var(--text-color-secondary);
}

.form-text {
  display: block;
  margin-top: var(--spacing-mini);
  font-size: var(--font-size-small);
  color: var(--text-color-tertiary);
}

/* 表单布局 */
.form-row {
  display: flex;
  flex-wrap: wrap;
  margin-right: calc(var(--spacing-small) * -1);
  margin-left: calc(var(--spacing-small) * -1);
}

.form-row > .form-group {
  padding-right: var(--spacing-small);
  padding-left: var(--spacing-small);
  flex: 1 0 0%;
}

/* 表单内联布局 */
.form-inline {
  display: flex;
  flex-flow: row wrap;
  align-items: center;
}

.form-inline .form-control {
  display: inline-block;
  width: auto;
  vertical-align: middle;
}

.form-inline .form-group {
  display: flex;
  flex: 0 0 auto;
  flex-flow: row wrap;
  align-items: center;
  margin-bottom: 0;
  margin-right: var(--spacing-medium);
}

/* 表单验证状态 */
.form-control.is-valid {
  border-color: var(--success-color);
  padding-right: calc(1.5em + 0.75rem);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3e%3cpath fill='%2328a745' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right calc(0.375em + 0.1875rem) center;
  background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.is-valid:focus {
  border-color: var(--success-color);
  box-shadow: 0 0 0 2px rgba(var(--success-color-rgb), 0.25);
}

.form-control.is-invalid {
  border-color: var(--error-color);
  padding-right: calc(1.5em + 0.75rem);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23dc3545' viewBox='0 0 12 12'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right calc(0.375em + 0.1875rem) center;
  background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.is-invalid:focus {
  border-color: var(--error-color);
  box-shadow: 0 0 0 2px rgba(var(--error-color-rgb), 0.25);
}

.valid-feedback {
  display: none;
  width: 100%;
  margin-top: var(--spacing-mini);
  font-size: var(--font-size-small);
  color: var(--success-color);
}

.invalid-feedback {
  display: none;
  width: 100%;
  margin-top: var(--spacing-mini);
  font-size: var(--font-size-small);
  color: var(--error-color);
}

.was-validated .form-control:valid ~ .valid-feedback,
.form-control.is-valid ~ .valid-feedback {
  display: block;
}

.was-validated .form-control:invalid ~ .invalid-feedback,
.form-control.is-invalid ~ .invalid-feedback {
  display: block;
}

/* 复选框和单选框 */
.form-check {
  position: relative;
  display: block;
  padding-left: 1.5rem;
  margin-bottom: var(--spacing-mini);
}

.form-check-input {
  position: absolute;
  margin-top: 0.25rem;
  margin-left: -1.5rem;
}

.form-check-label {
  margin-bottom: 0;
  cursor: pointer;
}

.form-check-inline {
  display: inline-flex;
  align-items: center;
  padding-left: 0;
  margin-right: var(--spacing-medium);
}

.form-check-inline .form-check-input {
  position: static;
  margin-top: 0;
  margin-right: 0.3125rem;
  margin-left: 0;
}

/* 自定义复选框和单选框 */
.custom-control {
  position: relative;
  z-index: 1;
  display: block;
  min-height: 1.5rem;
  padding-left: 1.5rem;
  margin-bottom: var(--spacing-mini);
  user-select: none;
}

.custom-control-input {
  position: absolute;
  left: 0;
  z-index: -1;
  width: 1rem;
  height: 1rem;
  opacity: 0;
}

.custom-control-label {
  position: relative;
  margin-bottom: 0;
  vertical-align: top;
  cursor: pointer;
}

.custom-control-label::before {
  position: absolute;
  top: 0.25rem;
  left: -1.5rem;
  display: block;
  width: 1rem;
  height: 1rem;
  pointer-events: none;
  content: "";
  background-color: var(--background-color-primary);
  border: 1px solid var(--border-color-normal);
}

.custom-control-label::after {
  position: absolute;
  top: 0.25rem;
  left: -1.5rem;
  display: block;
  width: 1rem;
  height: 1rem;
  content: "";
  background: no-repeat 50% / 50% 50%;
}

.custom-checkbox .custom-control-input:checked ~ .custom-control-label::before {
  border-color: var(--primary-color);
  background-color: var(--primary-color);
}

.custom-checkbox .custom-control-input:checked ~ .custom-control-label::after {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3e%3cpath fill='%23fff' d='M6.564.75l-3.59 3.612-1.538-1.55L0 4.26l2.974 2.99L8 2.193z'/%3e%3c/svg%3e");
}

.custom-radio .custom-control-label::before {
  border-radius: 50%;
}

.custom-radio .custom-control-input:checked ~ .custom-control-label::before {
  border-color: var(--primary-color);
  background-color: var(--primary-color);
}

.custom-radio .custom-control-input:checked ~ .custom-control-label::after {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
}

/* 开关 */
.custom-switch {
  padding-left: 2.25rem;
}

.custom-switch .custom-control-label::before {
  left: -2.25rem;
  width: 1.75rem;
  pointer-events: all;
  border-radius: 0.5rem;
}

.custom-switch .custom-control-label::after {
  top: calc(0.25rem + 2px);
  left: calc(-2.25rem + 2px);
  width: calc(1rem - 4px);
  height: calc(1rem - 4px);
  background-color: var(--border-color-normal);
  border-radius: 0.5rem;
  transition: transform 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.custom-switch .custom-control-input:checked ~ .custom-control-label::after {
  background-color: var(--background-color-primary);
  transform: translateX(0.75rem);
}

/* 选择框 */
.custom-select {
  display: inline-block;
  width: 100%;
  height: 36px;
  padding: var(--spacing-mini) var(--spacing-medium) var(--spacing-mini) var(--spacing-small);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  line-height: 1.5;
  color: var(--text-color-primary);
  vertical-align: middle;
  background-color: var(--background-color-primary);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3e%3cpath fill='%23343a40' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right var(--spacing-small) center;
  background-size: 8px 10px;
  border: 1px solid var(--border-color-normal);
  border-radius: var(--border-radius-base);
  appearance: none;
}

.custom-select:focus {
  border-color: var(--primary-color);
  outline: 0;
  box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.2);
}

/* 文件上传 */
.custom-file {
  position: relative;
  display: inline-block;
  width: 100%;
  height: 36px;
  margin-bottom: 0;
}

.custom-file-input {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 36px;
  margin: 0;
  opacity: 0;
}

.custom-file-label {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 1;
  height: 36px;
  padding: var(--spacing-mini) var(--spacing-small);
  font-weight: var(--font-weight-regular);
  line-height: 1.5;
  color: var(--text-color-primary);
  background-color: var(--background-color-primary);
  border: 1px solid var(--border-color-normal);
  border-radius: var(--border-radius-base);
}

.custom-file-label::after {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: block;
  height: 34px;
  padding: var(--spacing-mini) var(--spacing-small);
  line-height: 1.5;
  color: var(--text-color-primary);
  content: "浏览";
  background-color: var(--background-color-secondary);
  border-left: inherit;
  border-radius: 0 var(--border-radius-base) var(--border-radius-base) 0;
}

/* 范围滑块 */
.custom-range {
  width: 100%;
  height: 1.4rem;
  padding: 0;
  background-color: transparent;
  appearance: none;
}

.custom-range:focus {
  outline: none;
}

.custom-range::-webkit-slider-thumb {
  width: 1rem;
  height: 1rem;
  margin-top: -0.25rem;
  background-color: var(--primary-color);
  border: 0;
  border-radius: 1rem;
  appearance: none;
}

.custom-range::-webkit-slider-runnable-track {
  width: 100%;
  height: 0.5rem;
  color: transparent;
  cursor: pointer;
  background-color: var(--border-color-normal);
  border-color: transparent;
  border-radius: 1rem;
}

/* 飞书风格的表单元素 */
.lark-input {
  display: block;
  width: 100%;
  height: 36px;
  padding: var(--spacing-mini) var(--spacing-small);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  line-height: 1.5;
  color: var(--text-color-primary);
  background-color: var(--background-color-primary);
  background-clip: padding-box;
  border: 1px solid var(--border-color-normal);
  border-radius: var(--border-radius-base);
  transition: all 0.2s;
}

.lark-input:hover {
  border-color: var(--border-color-hover);
}

.lark-input:focus {
  border-color: var(--primary-color);
  outline: 0;
  box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.2);
}

.lark-input::placeholder {
  color: var(--text-color-tertiary);
  opacity: 1;
}

.lark-input-sm {
  height: 28px;
  padding: 2px 8px;
  font-size: var(--font-size-small);
}

.lark-input-lg {
  height: 44px;
  padding: 8px 12px;
  font-size: var(--font-size-medium);
}

.lark-input-group {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  width: 100%;
}

.lark-input-group .lark-input {
  position: relative;
  flex: 1 1 auto;
  width: 1%;
  min-width: 0;
  margin-bottom: 0;
}

.lark-input-group-prepend,
.lark-input-group-append {
  display: flex;
  align-items: center;
  padding: var(--spacing-mini) var(--spacing-small);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  line-height: 1.5;
  color: var(--text-color-secondary);
  text-align: center;
  white-space: nowrap;
  background-color: var(--background-color-secondary);
  border: 1px solid var(--border-color-normal);
}

.lark-input-group-prepend {
  border-right: 0;
  border-top-left-radius: var(--border-radius-base);
  border-bottom-left-radius: var(--border-radius-base);
}

.lark-input-group-append {
  border-left: 0;
  border-top-right-radius: var(--border-radius-base);
  border-bottom-right-radius: var(--border-radius-base);
}

.lark-input-group > .lark-input:not(:first-child) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.lark-input-group > .lark-input:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

/* 飞书风格的复选框 */
.lark-checkbox {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-right: var(--spacing-medium);
  cursor: pointer;
  user-select: none;
}

.lark-checkbox input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.lark-checkbox-checkmark {
  position: relative;
  height: 16px;
  width: 16px;
  background-color: var(--background-color-primary);
  border: 1px solid var(--border-color-normal);
  border-radius: 2px;
  margin-right: var(--spacing-mini);
  transition: all 0.2s;
}

.lark-checkbox:hover input ~ .lark-checkbox-checkmark {
  border-color: var(--border-color-hover);
}

.lark-checkbox input:checked ~ .lark-checkbox-checkmark {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.lark-checkbox-checkmark:after {
  content: "";
  position: absolute;
  display: none;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.lark-checkbox input:checked ~ .lark-checkbox-checkmark:after {
  display: block;
}

/* 飞书风格的单选框 */
.lark-radio {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-right: var(--spacing-medium);
  cursor: pointer;
  user-select: none;
}

.lark-radio input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.lark-radio-checkmark {
  position: relative;
  height: 16px;
  width: 16px;
  background-color: var(--background-color-primary);
  border: 1px solid var(--border-color-normal);
  border-radius: 50%;
  margin-right: var(--spacing-mini);
  transition: all 0.2s;
}

.lark-radio:hover input ~ .lark-radio-checkmark {
  border-color: var(--border-color-hover);
}

.lark-radio input:checked ~ .lark-radio-checkmark {
  border-color: var(--primary-color);
}

.lark-radio-checkmark:after {
  content: "";
  position: absolute;
  display: none;
  top: 3px;
  left: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-color);
}

.lark-radio input:checked ~ .lark-radio-checkmark:after {
  display: block;
}

/* 飞书风格的开关 */
.lark-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
  margin: 0;
  vertical-align: middle;
}

.lark-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.lark-switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-color-normal);
  transition: .4s;
  border-radius: 20px;
}

.lark-switch-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

.lark-switch input:checked + .lark-switch-slider {
  background-color: var(--primary-color);
}

.lark-switch input:focus + .lark-switch-slider {
  box-shadow: 0 0 1px var(--primary-color);
}

.lark-switch input:checked + .lark-switch-slider:before {
  transform: translateX(20px);
}

/* 飞书风格的表单布局 */
.lark-form {
  margin-bottom: var(--spacing-large);
}

.lark-form-item {
  margin-bottom: var(--spacing-medium);
  display: flex;
  flex-wrap: wrap;
}

.lark-form-label {
  display: inline-block;
  flex: 0 0 120px;
  text-align: right;
  padding-right: var(--spacing-medium);
  line-height: 36px;
  font-size: var(--font-size-base);
  color: var(--text-color-secondary);
}

.lark-form-content {
  flex: 1;
  min-width: 0;
}

.lark-form-help {
  margin-top: var(--spacing-mini);
  font-size: var(--font-size-small);
  color: var(--text-color-tertiary);
}

.lark-form-error {
  margin-top: var(--spacing-mini);
  font-size: var(--font-size-small);
  color: var(--error-color);
}

/* 响应式表单 */
@media (max-width: 576px) {
  .lark-form-item {
    flex-direction: column;
  }
  
  .lark-form-label {
    flex: 0 0 100%;
    text-align: left;
    margin-bottom: var(--spacing-mini);
    line-height: 1.5;
    padding-right: 0;
  }
}